package com.imooc.mall.exception;


// 枚举类中一个类中有多个实例的方法，可以有以下的实例， 每一个实例都会调用构造方法来实例化对象的
public enum ImoocMallExceptionEnum {
    ENUM_USER_NUME(10001,"用户名不能为空"),
    ENUM_USER_PASSWORD(10002,"密码不能为空"),
    ENUM_PASSWORD_SHORT(10003,"密码长度不够"),
    NAME_EXISTED(10004,"不能重名字，注册失败"),
    INSERT_FAILED(10005,"插入失败请重试"),
    WRONG_PASSWORD(10006,"密码错误"),
    NEED_LOGIN(10007,"用户未登录"),
    UPDATE_FAILED(10008,"更新失败"),
    NEED_ADMIN(10009,"无管理员权限"),



    PARA_NOT_NULL(10010,"参数不能为空"),
    CREATE_FAILED(10011,"新增加失败"),
    REQUEST_PARAM_ERROR(10012,"参数错误"),
    MKDIR_FAILED(10013,"文件创建失败"),
    PRODUCT_NUME(10014,"商品不存在失败"),

    DELETE_FAILED(10012,"删除失败"),
    UPLOAD_FAILED(100014,"图片上传失败"),
    NOT_SALE(100015,"商品状态异常"),
    NOT_ENOUGH(100016,"库存不足"),
    CART_EMPTY(100018,"商品添加为空"),
    NOT_ENUM(100019,"未找到对应的枚举类"),
    NOT_ORDER(100020,"订单不存在"),
    NOT_YOUR_ORDER(100021,"订单不属于你"),
    NOT_ON_ORDER(100022,"订单状态不符合"),
    WRONG_ORDER_STATUS(100023,"订单状态不符合"),



    SYSTEM_ERROR(20000,"系统异常");


    /*
    * 异常状态码
    * */
    Integer code;
    /*
     *  异常信息
     * */
    String msg;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    // 泛型实例是不能有这个Public 方法公开的
//
//    public static ImoocMallExceptionEnum getCodeMessage( Integer code){
//        for (ImoocMallExceptionEnum imoocMallExceptionEnum :values()){
//            if (imoocMallExceptionEnum.getCode() == code ){
//             return imoocMallExceptionEnum;
//            }
//
//        }
//        throw new ImoocMallException(ImoocMallExceptionEnum.getCodeMessage(30));
//    }

    ImoocMallExceptionEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
